<?php
class ShippingAction extends CommonAction {
	function index(){
        $myid=D('User')->where(' id = '.session(C('USER_AUTH_KEY')))->getField('member_id');
        $this->listmap='site_id = '.__SITEID__;
        if($_GET['keywords']){
            $this->listmap= ' and title like "%'.$_GET['keywords'].'%';
        }
        if($myid){
            $this->listmap.=' and  member_id = '.$myid;
        }else{
            $this->listmap .= ' and member_id = 0';
        }
        $this->listorder='sort';
        parent::_list();
		$this->display();
	}
	
	public function template(){
		$info = $this->dao -> where(array('site_id' => $this->siteid, 'id' => $this->_get("id"))) -> find();
		$this->assign('info', $info);
		$this->display();
	}
	public function insert(){
	    $data=$_POST;
        $myid=D('User')->where(' id = '.session(C('USER_AUTH_KEY')))->getField('member_id');
        $myid = $myid?$myid:0;
	    $data['member_id']=$myid;
        $data['sort']=D('shipping')->where('member_id = '.$myid)->order('sort desc')->getfield('sort');
        $data['sort']++;
	    parent::insert($data);
    }
}